var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    }; Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("BaseModuleUI"),
    n = e("NotifyEventType"),
    i = e("GlobalParams"),
    r = e("AudioManager"),
    s = e("Game"),
    l = e("season_item_node"),
    _ = cc._decorator,
    c = _.ccclass,
    d = _.property,
    h = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.season_content_view = null),
                (t.season_item_node = null),
                (t.season_scroll_view = null),
                (t.award_level_label = null),
                (t.award_type_node = []),
                (t.award_num_label = []),
                (t.get_hero_btn = null),
                (t.min_count_num = 0),
                (t.max_count_num = 0),
                (t.show_season_index = 0),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.initView = function () {
                e.prototype.initView.call(this);
                var t = i.GlobalParams.PlayerInfo.value;
                (this.min_count_num = t.level - 3),
                    (this.min_count_num = this.min_count_num < 1 ? 1 : this.min_count_num),
                    (this.max_count_num = t.level < 5 ? 8 : t.level + 4),
                    (this.max_count_num = this.max_count_num > 71 ? 71 : this.max_count_num);
                for (var o = 0; o < this.season_content_view.childrenCount; o++)
                    this.season_content_view.children[o].active = !1;
                this.addSeasonNode(this.min_count_num, this.max_count_num),
                    this.season_scroll_view.getComponent(cc.ScrollView).scrollToLeft(),
                    this.showGetHeroInfo();
            }),
            (t.prototype.addEvent = function () {
                this.season_scroll_view.on("scroll-to-left", this.scollToLeft, this),
                    this.season_scroll_view.on("scroll-to-right", this.scollToRight, this),
                    this.attachEvent(n.default.SEND_UPDATE_PLAYER_SEASON_LEVEL_INFO, this.showGetHeroInfo, this),
                    this.get_hero_btn.node.on("click", this.getHeroInfo, this);
            }),
            (t.prototype.showGetHeroInfo = function () {
                var e = i.GlobalParams.PlayerInfo.value,
                    t = i.GlobalParams.playerSkinInfo.value;
                this.get_hero_btn.interactable = e.level > 70 && -1 == t.have_hero.indexOf(8);
            }),
            (t.prototype.getHeroInfo = function () {
                r.default.ButtonSound();
                var e = i.GlobalParams.playerSkinInfo.value;
                e.have_hero.push(8), (i.GlobalParams.playerSkinInfo.value = e), this.showGetHeroInfo();
            }),
            (t.prototype.scollToLeft = function () {
                if (this.min_count_num > 1) {
                    var e = this.min_count_num;
                    (this.min_count_num -= 5),
                        (this.min_count_num = this.min_count_num < 1 ? 1 : this.min_count_num),
                        this.addSeasonNode(this.min_count_num, e);
                }
            }),
            (t.prototype.scollToRight = function () {
                if (this.max_count_num < 71) {
                    var e = this.max_count_num;
                    (this.max_count_num += 5),
                        (this.max_count_num = this.max_count_num > 71 ? 71 : this.max_count_num),
                        this.addSeasonNode(e, this.max_count_num);
                }
            }),
            (t.prototype.addSeasonNode = function (e, t) {
                for (var o = e; o < t; o++) {
                    var a = null;
                    this.season_content_view.children[o - 1]
                        ? (a = this.season_content_view.children[o - 1])
                        : (a = cc.instantiate(this.season_item_node)).setParent(this.season_content_view),
                        (a.active = !0),
                        a.getComponent(l.default).showSeasonInfo(o - 1);
                }
            }),
            (t.prototype.onCollisionEnter = function (e) {
                var t,
                    o = e.node;
                if (((t = o.zIndex < 5 ? 5 : 5 * Math.ceil((o.zIndex + 1) / 5)), this.show_season_index != t)) {
                    this.show_season_index = t;
                    var a = this.show_season_index;
                    this.award_level_label.string = "" + a;
                    var n = s.default.season_info[a - 1];
                    (this.award_type_node[0].parent.active = 1 == n.award_type.length),
                        (this.award_type_node[1].parent.active = n.extra_type.length < 3),
                        (this.award_type_node[2].parent.active = 2 == n.extra_type.length);
                    for (var i = 0; i < 3; i++) {
                        var r = 0 == i ? n.award_type : n.extra_type,
                            l = 0 == i ? n.award_num : n.extra_num;
                        if (this.award_type_node[i].parent.active)
                            for (var _ = 0; _ < 5; _++)
                                0 == i
                                    ? ((this.award_type_node[i].children[_].active = -1 != r.indexOf(_)),
                                        -1 != r.indexOf(_) && (this.award_num_label[i].string = "" + l[i]))
                                    : ((this.award_type_node[i].children[_].active = _ == r[i - 1]),
                                        _ == r[i - 1] && (this.award_num_label[i].string = "" + l[i - 1]));
                    }
                }
            }),
            oo([d(cc.Node)], t.prototype, "season_content_view", void 0),
            oo([d(cc.Node)], t.prototype, "season_item_node", void 0),
            oo([d(cc.Node)], t.prototype, "season_scroll_view", void 0),
            oo([d(cc.Label)], t.prototype, "award_level_label", void 0),
            oo([d(cc.Node)], t.prototype, "award_type_node", void 0),
            oo([d(cc.Label)], t.prototype, "award_num_label", void 0),
            oo([d(cc.Button)], t.prototype, "get_hero_btn", void 0),
            oo([c], t)
        );
    })(a.default);
o.default = h;
